home *** CD-ROM | disk | FTP | other *** search
- /*
- *
- * © Copyright 1991, Rob Glanville
- *
- * by Rob Glanville
- *
- * 17 June 91
- *
- * EthernetTests.c - Channel command based ethernet tests.
- *
- */
-
- /*
- *
- * This module tests the MACE Ethernet peripheral using the channel command
- * structure outlined for the Mazda RISC engine. A pointer to a parameter
- * block is passed and this block is only used to return the results. This
- * module was primarily written for bring-up and performs five tests. Some
- * portions of the tests require an external analyzer to capture the results
- * and generate packet traffic.
- *
- * Some hard facts:
- * 1) The data is always an incrementing pattern and is 1500 bytes long
- * 2) The destination address for the first packet will be 1000E0280877
- * which is the address of an Ethernet NuBus card.
- * 3) The source address will be 526F6220472E (Rob G.)
- * 4) The packets will have the following format;
- * 6 bytes for destination address, 6 bytes for source address, 2 bytes
- * for command or length, 1500 bytes for data, 4 bytes for CRC. 1518 Total
- * 5) CRC data is appended to the packet by MACE hardware.
- *
- */
-
- /* Miscellanious defines */
- #define UBYTE unsigned char
- #define UWORD unsigned short
- #define ULONG unsigned long
- #define Null 0x00000000
- #define True 0xFFFFFFFF
- #define False 0x00000000
- #define PBYTE *(unsigned char *) /* Used for physical address casting */
- #define PWORD *(unsigned short *) /* Used for physical address casting */
- #define PLONG *(unsigned long *) /* Used for physical address casting */
-
- /* Define possible tests */
- #define TestTx 0x01
- #define TestRx 0x02
- #define TestTxRx 0x03
-
- /* Ethernet channel commands */
- #define Configure 0x01
- #define TxCmd 0x02
- #define GetStatus 0x03
- #define RxCmd 0x04
-
- #define CmdPointer 0x00000000 /* Regsiter that holds the channel command pointer */
- #define InUse 0x80 /* Set the flag bit for command in use */
- #define TestSize 124
-
- /**************************** Variable area ****************************/
-
- /* Define the parameter block that controls the test */
- struct PB {
- /* Put parameters here */
- /* Put results here */
- UWORD status;
- } PB;
-
- /* Carve out some space for channel commands */
- struct CC {
- UBYTE command;
- UBYTE flags;
- UWORD length;
- ULONG address;
- } CC[0x20];
-
- /* Transmit buffer */
- struct {
- UBYTE Destination[6];
- UBYTE Source[6];
- UWORD Length;
- UBYTE Buffer[1500];
- /* The transmit source is four byte longer than the */
- } TxPacket;
-
- /* Receive buffer */
- struct {
- UBYTE Destination[6];
- UBYTE Source[6];
- UWORD Length;
- UBYTE Buffer[1500];
- ULONG CRC;
- } RxPacket;
-
- /*************************** Constant Area *****************************/
-
- MyNode[6] = {0x52,0x6F,0x62,0x20,0x47,0x2E}; /* Source node */
- YourNode[6] = {0x10,0x00,0xE0,0x28,0x08,0x77}; /* Destination node */
-
- /***************************** Code Area *******************************/
-
- void MakeTxPacket(ULONG length) {
- UWORD index;
- /* Set source and destination addresses */
- for (index=0;index<6;index++) {
- TxPacket.Destination[index] = YourNode[index];
- TxPacket.Source[index] = MyNode[index];
- }
- TxPacket.Length = Null; /* May be used later for variable packets */
- /* Fill in the data field */
- for (index=0;index<length;index++) {
- TxPacket.Buffer[index] = index;
- }
- }
-
- /*
- * This routine compares the data in the receive buffer. There are
- * several data types that are defined. This type is passed as a parameter
- * and is used to define the data for comparison
- * Type should be one of the follwoing values;
- * 0x00, 0x55, 0xAA, 0xFF, or 0x6A ('i' for incrementing from zero)
- * The node address, length field, and CRC are not compared
- */
- ComparePacket(UBYTE Type, ULONG length) {
- ULONG index;
- UBYTE failure = False;
- if (Type = 'i') { /* incrementing pattern */
- for (index=0;index<length;index++) {
- if (RxPacket.Buffer[index] != index) {
- failure = True;
- break;
- }
- }
- }
- else { /* Non incrementing */
- for (index=0;index<length;index++) {
- if (RxPacket.Buffer[index] != Type) {
- failure = True;
- break;
- }
- }
- }
- }
-
- TestTransmit() {
- UWORD CommandPointer;
- /* Build packet */
- MakeTxPacket(TestSize);
- /* Build tx channel command */
- CommandPointer = 0; /* Point to first command */
- CC[CommandPointer].command = TxCmd;
- CC[CommandPointer].flags = InUse;
- CC[CommandPointer].length = 124; /* 4 byte are appended for CRC */
- CC[CommandPointer].address = &TxPacket;
- /* Set channel command pointer in Mazda */
- /* Wait for the results */
- }
-
- TestReceive() {
- UWORD CommandPointer;
- /* Build rx channel command */
- CommandPointer = 0; /* Point to first command */
- CC[CommandPointer].command = RxCmd;
- CC[CommandPointer].flags = InUse;
- CC[CommandPointer].length = 128;
- CC[CommandPointer].address = &RxPacket;
- /* Set channel command pointer in Mazda */
- }
-
- TestTransmitAndReceive() {
- }
-
- InitializeEthernet() {
- /* Create initialization data block in memory */
- /* Send Initialization command to Ethernet */
- }
-
- TestEthernet(TestType) {
- InitializeEthernet();
- switch(TestType) {
- case TestTx :
- TestTransmit();
- break;
- case TestRx :
- TestReceive();
- break;
- case TestTxRx :
- TestTransmitAndReceive();
- break;
- default :
- /* Set error code for internal software error */
- break;
- }
- }